<style>
    .content {
        background-color: #ffffff;
    }
    .content-wrapper>.content {
        padding: 0;
    }
</style>
<div id="toolbar" class="toolbar">
    <button type="button" class="btn btn-secondary btn-refresh" data-toggle="tooltip" data-popup="false" data-placement="top" title="" data-original-title="{:lang('Reload page')}"><i class="fas fa-redo-alt"></i></button>
    <button type="button" class="btn btn-primary btn-add " data-url="{:url('/cms.archives/add',['category_id'=>$category_id])}"><i class="fas fa-plus"></i> {:lang('Add')}</button>
    <button type="button" class="btn btn-disabled btn-danger disabled btn-del" data-url="{:url('/cms.archives/del',['category_id'=>$category_id])}"><i class="fas fa-trash-alt"></i>
        {:lang("Delete")}</button>
    <div class="dropdown mr-1 btn-toggle">
        <a class="btn btn-secondary dropdown-toggle btn-disabled disabled" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            <i class="fas fa-"></i> {:lang('Setting')}
        </a>
        <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
            <a class="dropdown-item" href="#" data-params="status=normal">{:lang('Set to normal')}</a>
            <a class="dropdown-item" href="#" data-params="status=reject">{:lang('Set as rejected')}</a>
            <a class="dropdown-item" href="#" data-params="status=audit">{:lang('Set Pending')}</a>
            <a class="dropdown-item" href="#" data-params="status=hidden">{:lang('Settings disabled')}</a>
        </div>
    </div>
    &nbsp;<button type="button" class="btn btn-primary btn-recycle" data-url="{:url('/cms.archives/recycle',['category_id'=>$category_id])}"><i class="fas fa-trash-restore"></i> {:lang('Recycle')}</button>
</div>

<div class="filter-panel d-none">
    <form action="" method="get" class="frm-filter">
<!--        <input type="hidden" name="category_id" value="{$category_id}">-->
        <div class="row">
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <div class="form-group row">
                    <label class="col-md-4 col-sm-4 col-xs-6 mb-0 pt-2 text-right">ID</label>
                    <div class="col-md-8 col-sm-8 col-xs-6">
                        <input type="text" class="form-control" name="ID" placeholder="ID">
                    </div>
                </div>
            </div>
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <div class="form-group row">
                    <label class="col-md-4 col-sm-4 col-xs-6 mb-0 pt-2 text-right">{:lang("Title")}</label>
                    <div class="col-md-8 col-sm-8 col-xs-6">
                        <input type="text" class="form-control" name="title" placeholder="{:lang("Title")}" data-op="like %...%">
                    </div>
                </div>
            </div>
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <div class="form-group row">
                    <label class="col-md-4 col-sm-4 col-xs-6 mb-0 pt-2 text-right">{:lang("Publisher")}</label>
                    <div class="col-md-8 col-sm-8 col-xs-6">
                        <input type="text"
                               id="frm-admin_id"
                               class="form-control selectpage"
                               name="admin_id"
                               data-multiple="true"
                               data-op="IN"
                               placeholder=""
                               data-show-field="username"
                               data-search-field="username"
                               data-data="{:url('/auth.admin/index')}">
                    </div>
                </div>
            </div>
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <div class="form-group row">
                    <label class="col-md-4 col-sm-4 col-xs-6 mb-0 pt-2 text-right">{:lang("Release time")}</label>
                    <div class="col-md-8 col-sm-8 col-xs-6">
                        <input type="text"
                               class="form-control laydate"
                               id="frm-publish_time"
                               name="publish_time"
                               data-type="datetime"
                               data-range="true"
                               data-op="BETWEEN TIME"
                               autocomplete="off"
                               placeholder="{:lang("Release time")}">
                    </div>
                </div>
            </div>
            <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
                <div class="form-group text-center">
                    <input type="submit" class="btn btn-primary ml-2" value="{:lang('Search')}">
                    <input type="reset" class="btn btn-default" value="{:lang('Reset')}">
                </div>
            </div>
        </div>
    </form>
</div>

<table id="table"
       data-edit="{:url('/cms.archives/edit',['category_id'=>$category_id])}"
       data-del="{:url('/cms.archives/del',['category_id'=>$category_id])}"
       data-batches="{:url('/cms.archives/batches',['category_id'=>$category_id])}" data-popup="false"></table>

{block:script}
<script>
    require(['jquery','layer','cmsTable'], function ($, undefined, cmsTable) {
        $(function () {
            cmsTable.init({
                url: "{:url('/cms.archives/index',['model_id'=>$model_id,'category_id'=>$category_id])}",
                sortName: 'update_time',
                customFilter: true,
                addCallback: function(data) { // data属性字段值
                    if (data.popup!==false) {
                        parent.window.cmsOpen(Util.setUrlParams({ url:data.url, query:{popup:1} }),'{:lang('Add')}')
                        return false;
                    }
                },
                editCallback: function(data, ids) {
                    if (data.popup!==false) {
                        if (Array.isArray(ids)) {
                            $.each(ids, function (key, value) {
                                parent.window.cmsOpen(Util.setUrlParams({ url:data.url, query:{popup:1,id:value }}), '{:lang('Edit')}');
                            });
                        } else {
                            parent.window.cmsOpen(Util.setUrlParams({ url:data.url,query:{popup:1,id:ids}}), '{:lang('Edit')}');
                        }
                        return false;
                    }
                },
                columns: [{
                    field: 'state',
                    checkbox: true,
                },{
                    field: 'weigh',
                    title: '{:lang("Weigh")}',
                    formatter:cmsTable.formatter.txtEditBtn,
                    events:cmsTable.events.txtEditBtn
                },{
                    field: 'id',
                    title: 'ID'
                },{
                    field: 'title',
                    title: '{:lang("Title")}',
                    formatter: function (value,row,index) {
                        return '<a class="text-info" href="'+row['url']+'" target="_blank">'+value+'</a>';
                    }
                },{
                    field: 'category_title',
                    title: '{:lang("Column")}'
                },{
                    field: 'views',
                    title: '{:lang("Click volume")}'
                },{
                    field: 'username',
                    title: '{:lang("Publisher")}'
                },{
                    field: 'publish_time_text',
                    title: '{:lang("Release time")}'
                },{
                    field: 'status',
                    title: '{:lang("Status")}',
                    formatter: function (value,row,index) {
                        if (value=='normal') {
                            return '<span class="text-primary">'+lang(value)+'</span>';
                        } else if (value=='reject') {
                            return '<span class="text-danger">'+lang(value)+'</span>';
                        } else if (value=='audit') {
                            return '<span class="text-warning">'+lang(value)+'</span>';
                        } else if (value=='hidden') {
                            return '<span class="text-dark">'+lang(value)+'</span>';
                        } else {
                            return value;
                        }
                    }
                },{
                    field: 'operate',
                    title: '{:lang("Operate")}',
                    formatter: cmsTable.formatter.operate,
                    events: cmsTable.events.operate
                }]});
        })
    })
</script>
{/block:script}